/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.orhandemirel.jabif;

/**
 *
 * @author Selcuk Orhan DEMIREL <orhandemirel@msn.com>
 */
public class DirEntry {

    enum DataType
    {
        BYTE(1,1),
        CHAR(2,1),
        WORD(3,2),
        SHORT(4,2),
        LONG(5,4),
        FLOAT(7,4),
        DOUBLE(8,8),
        DATE(10,4),
        TIME(11,4),
        PSTRING(18,1),
        CSTRING(19,1),
        UNSUPPORTED(0,0);


        private int id;
        private int elemsize;

        private DataType(int id, int elemsize)
        {
            this.id = id;
            this.elemsize = elemsize;
        }

        public int getElemSize()
        {
            return elemsize;
        }

        public int getId()
        {
            return id;
        }

    }

    
    private String name;
    private int number;
    private short elementtype;
    private DataType type;
    private short elementsize;
    private int numelements;
    private int datasize;
    private int dataoffset;
    private int datahandle;

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the number
     */
    public int getNumber() {
        return number;
    }

    /**
     * @param number the number to set
     */
    public void setNumber(int number) {
        this.number = number;
    }

    /**
     * @return the elementtype
     */
    public short getElementtype() {
        return elementtype;
    }

    /**
     * @param elementtype the elementtype to set
     */
    public void setElementtype(short elementtype) {
        this.elementtype = elementtype;
        this.setType(elementtype);
    }

    /**
     * @return the elementsize
     */
    public short getElementsize() {
        return elementsize;
    }

    /**
     * @param elementsize the elementsize to set
     */
    public void setElementsize(short elementsize) {
        this.elementsize = elementsize;
    }

    /**
     * @return the numelements
     */
    public int getNumelements() {
        return numelements;
    }

    /**
     * @param numelements the numelements to set
     */
    public void setNumelements(int numelements) {
        this.numelements = numelements;
    }

    /**
     * @return the datasize
     */
    public int getDatasize() {
        return datasize;
    }

    /**
     * @param datasize the datasize to set
     */
    public void setDatasize(int datasize) {
        this.datasize = datasize;
    }

    /**
     * @return the dataoffset
     */
    public int getDataoffset() {
        return dataoffset;
    }

    /**
     * @param dataoffset the dataoffset to set
     */
    public void setDataoffset(int dataoffset) {
        this.dataoffset = dataoffset;
    }

    /**
     * @return the datahandle
     */
    public int getDatahandle() {
        return datahandle;
    }

    /**
     * @param datahandle the datahandle to set
     */
    public void setDatahandle(int datahandle) {
        this.datahandle = datahandle;
    }

    /**
     * @return the type
     */
    public DataType getType() {
        return type;
    }

    public void setType(int elementtype)
    {
        switch(elementtype)
        {
            case 1:
                this.type = DataType.BYTE;
                break;
            case 2:
                this.type = DataType.CHAR;
                break;
            case 3:
                this.type = DataType.WORD;
                break;
            case 4:
                this.type = DataType.SHORT;
                break;
            case 5:
                this.type = DataType.LONG;
                break;
            case 7:
                this.type = DataType.FLOAT;
                break;
            case 8:
                this.type = DataType.DOUBLE;
                break;
            case 10:
                this.type = DataType.DATE;
                break;
            case 11:
                this.type = DataType.TIME;
                break;
            case 18:
                 this.type = DataType.PSTRING;
                break;
            case 19:
                 this.type = DataType.CSTRING;
                break;
            default:
                this.type = DataType.UNSUPPORTED;

        }
    }

}